   var $table = $('#table');
    $(function() {
    $(document).on('focus', 'input[type="text"]', function() {
        $(this).parent().find('label').addClass('active');
    }).on('blur', 'input[type="text"]', function() {
        if ($(this).val() == '') {
            $(this).parent().find('label').removeClass('active');
        }
    });
    $table.bootstrapTable({
    url: '/client/allSurvey?act1=load',
    method: 'get',
    contentType: "application/x-www-form-urlencoded",
    queryParams: function queryParams(params) {   //设置查询参数
        return {
                pageNumber: params.pageNumber,
                pageSize: params.pageSize,
            };
        },
    height: getHeight(),
    striped: true,
    searchOnEnterKey: true,
    showRefresh: true,
    showToggle: true,
    showColumns: true,
    minimumCountColumns: 2,
    showPaginationSwitch: true,
    clickToSelect: true,
    detailView: true,
    detailFormatter: 'detailFormatter',
    pagination: true,
    paginationLoop: false,
    classes: 'table table-hover table-no-bordered',
    //sidePagination: 'server',
    //silentSort: false,
    smartDisplay: false,
    idField: 'id',
    sortName: 'id',
    sortOrder: 'desc',
    escape: true,
    searchOnEnterKey: true,
    idField: 'systemId',
    maintainSelected: true,
    toolbar: '#toolbar',
    columns: [
        {field: 'state', checkbox: true},
        {field: 'id', title: '问卷编号', sortable: true, halign: 'center'},
        {field: 'start', title: '问卷开始时间', sortable: true, halign: 'center'},
        {field: 'end', title: '问卷结束时间', sortable: true, halign: 'center'},
        {field: 'title', title: '问卷名称', sortable: true, halign: 'center'},
        {field: 'questionCount', title: '题目数量', sortable: true, halign: 'center'},
        {field: 'status', title: '状态', sortable: true, halign: 'center'},
        {field: 'link', title: '问卷链接', sortable: true, halign: 'center'},
    ]
}).on('all.bs.table', function (e, name, args) {
    $('[data-toggle="tooltip"]').tooltip();
    $('[data-toggle="popover"]').popover();
});
});

    window.actionEvents = {
//     'click .like': function (e, value, row, index) {
//     alert('You click like icon, row: ' + JSON.stringify(row));
//     console.log(value, row, index);
// },
    'click .edit': function (e, value, row, index) {
    alert('You click edit icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
},
    'click .remove': function (e, value, row, index) {
    alert('You click remove icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
}
};
    function detailFormatter(index, row) {
    var html = [];
    $.each(row, function (key, value) {
    html.push('<p><b>' + key + ':</b> ' + value + '</p>');
});
    return html.join('');
}

    // 新增
    function createAction() {
    $.confirm({
        type: 'dark',
        animationSpeed: 300,
        centered: true,
        title: '新增问卷',
        content: $('#createDialog').html(),
        buttons: {
            // confirm: {
            //     text: '确认',
            //     btnClass: 'waves-effect waves-button',
            //     action: function () {
            //         $.alert('确认');
            //         var count = $('#table').bootstrapTable('getData').length;
            //         var inputName = this.$content.find('#input1').val();
            //         console.info("名字"+inputName);
            //         $('#table').bootstrapTable('insertRow',{index:count,
            //             row:{
            //                 id:count+1,
            //                 name:inputName,
            //                 status:'未提交',
            //                 halign: 'center'}});
            //                 window.parent.location.href = "../jsp/CreateQuestionnaire.jsp";
            //     }
            // },
            cancel: {
                text: '取消',
                btnClass: 'waves-effect waves-button'
            }
        }
    });
}
   // 删除
   function deleteAction() {
       $.confirm({
           type: 'red',
           animationSpeed: 300,
           centered: true,
           title: '删除问卷',
           content: $('#deleteDialog').html(),
           buttons: {
               cancel: {
                   text: '取消',
                   btnClass: 'waves-effect waves-button'
               }
           }
       });
   }
    // 编辑
    function updateAction() {
        $.confirm({
            type: 'green',
            animationSpeed: 300,
            centered: true,
            title: '编辑问卷',
            content: $('#editDialog').html(),
            buttons: {
                cancel: {
                    text: '取消',
                    btnClass: 'waves-effect waves-button'
                }
            }
        });
    }
